<template>
  <div>
    <!-- 待配送 -->
    <div v-if="goodslist.status === 1">
      <van-button round @click="ConfirmDelivery">确 认 收 货</van-button>
    </div>
    <!-- 待支付 -->
    <div v-else-if="goodslist.status === 0">
      <van-button round @click="ConfirmPay">确认并支付(微信支付)</van-button>
    </div>
    <!-- 待配送 -->
    <div v-else-if="goodslist.status === 2">
      <van-button round @click="ConfirmDelivery">确 认 收 货</van-button>
    </div>
    <!-- 已收货 -->
    <!-- 售后退款 -->
    <div v-else-if="goodslist.status === 4">
      <van-button round @click="ConfirmRefund">确 认 退 款</van-button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'GoodsConfrim',

  props: {
    goodslist: {
      type: Object,
      required: true
    }
  },
  data () {
    return {

    }
  },
  created () {

  },
  mounted () {

  },
  methods: {
    ConfirmPay () {
      this.$router.push({ name: 'pay' }) // 放跳转到待支付页面的名字
    },
    ConfirmRefund () {
      this.$dialog.confirm({
        title: '确认退款',
        message: '你确定要退款吗'
      })
        .then(() => {
          this.$emit('confirm_refund', 5)
          this.$toast.success('已成功退款')
        })
        .catch(() => {
          return false
        })
    },
    ConfirmDelivery () {
      this.$dialog.confirm({
        title: '确认收货',
        message: '你已经收到货了吗'
      })
        .then(() => {
          this.$emit('confirm_delivery', 3)
          this.$toast.success('已收货')
        })
        .catch(() => {
          return false
        })
    }
  }
}
</script>

<style scoped lang="less">
.van-button {
  color: #fff;
  background-color: rgb(243, 70, 64);
  width: 100%;
}
</style>
